package com.lyltim.demo.controller;

import com.lyltim.demo.bean.Order;
import com.lyltim.demo.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class OrderController {

    @Autowired
    private OrderMapper orderMapper;

    @GetMapping("/addOrder")
    public String addOrder() {
        orderMapper.insertOrder(new Order(1,1,1,666));
        return "addOrder() OK";
    }

    @GetMapping("/getOrder")
    public Order getOrder() {
        return orderMapper.getOrderById(2);
    }

    @GetMapping("/getOrders")
    public List<Order> getOrders() {
        return orderMapper.getOrders();
    }

    @GetMapping("/deleteOrder")
    public String deleteOrder() {
        orderMapper.deleteOrderById(1);
        return "deleteOrder ok";
    }
}
